---
kind: Job
apiVersion: batch/v1
metadata:
  generateName: grep-contents-
  namespace: "{{ namespace }}"
spec:
  completions: 1
  parallelism: 1
{% if local_should_fail %}
  backoffLimit: 0
{% else %}
  backoffLimit: 999
{% endif %}
  template:
    spec:
      containers:
        - name: busybox
          image: gcr.io/distroless/static:debug
          imagePullPolicy: IfNotPresent
          command: ["sh", "-c"]
          args:
            - |
              set -x -e -o pipefail

              id
              stat '/mnt/{{ path }}'
              grep '{{ data }}' '/mnt/{{ path }}'
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop: ["ALL"]
            readOnlyRootFilesystem: true
          volumeMounts:
            - name: pvc
              mountPath: "/mnt"
      restartPolicy: Never
{% if podSecurityContext is defined %}
      securityContext: {{ podSecurityContext }}
{% endif %}
      terminationGracePeriodSeconds: 2
      volumes:
        - name: pvc
          persistentVolumeClaim:
            claimName: "{{ pvc_name }}"
